package net.xumf.dao.master;

import net.xumf.domain.master.SystemRole;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface SystemRoleRepository extends PagingAndSortingRepository<SystemRole, Integer> {

    List<SystemRole> findByRoleIdIn(List<Integer> roleIds);

    @Query(value = "SELECT sr FROM SystemRole sr WHERE sr.name like %?1%",
            countQuery = "SELECT count(sr) FROM SystemRole sr WHERE sr.name like %?1%")
    Page<SystemRole> findByName(String name, Pageable pageable);

    Page<SystemRole> findByNameContainingAndStatus(String name, Integer status, Pageable pageable);

    Page<SystemRole> findByNameContaining(String name, Pageable pageable);

}